package com.pa165.languageschoolpersistence.DAO;

import com.pa165.languageschoolpersistence.Exceptions.IllegalArgumentPersistenceException;
import com.pa165.languageschoolpersistence.Exceptions.ServiceFailureException;
import com.pa165.languageschoolpersistence.entities.Course;
import com.pa165.languageschoolpersistence.entities.LanguageSpoken;
import java.util.List;

/**
 *
 * @author Tomas Hruby
 *
 * This Interface represents DAO for handling Courses It contains basic CRUD
 * operations. Lectures(more) can be assigned to a Course(one). All assigned
 * lectures can be obtained by getAssignedLectures() . Then additional
 * operations are added : - finder by language - finder by name
 */
public interface CourseDAO {

    // public void setEntityFactory(EntityManagerFactory emf);
    /**
     * Method for adding Courses. For conventions of a valid course see Course
     * entity. If a course is not in the database, it returns the course added.
     * If a course is already in the database, it returns a null value.
     *
     * @param course course to be added.
     * @return Null if already in database, Course added instead
     * @throws IllegalArgumentPersistenceException if course is invalid
     * @throws ServiceFailureException if a problem during adding occures.
     */
    public Course add(Course course) throws ServiceFailureException;

    /**
     * Method for removing Courses. For conventions of a valid course see Course
     * entity.
     *
     * @param course course to be removed.
     * @throws IllegalArgumentPersistenceException if course is invalid
     * @throws ServiceFailureException is a problem during removal occures or if
     * course is already in the database.
     */
    public void remove(Course course) throws IllegalArgumentPersistenceException;

    /**
     * Method for modifying Courses. For conventions of a valid course see
     * Course entity.
     *
     * @param course course to be modified.
     * @return Modified Course.
     * @throws IllegalArgumentPersistenceException if course is invalid
     * @throws ServiceFailureException if a problem during adding occures or if
     * course is not in the database.
     */
    public Course modify(Course course) throws IllegalArgumentPersistenceException;

    /**
     * Method for retrieving Courses. For conventions of a valid course see
     * Course entity. Method gets course by input ID.
     *
     * @param id ID to be searched for.
     * @return Null if not in database, Course found instead
     * @throws IllegalArgumentPersistenceException if id is invalid(for details
     * see Course entity)
     * @throws ServiceFailureException if a problem during search occures.
     */
    public Course get(Long id) throws IllegalArgumentPersistenceException;

    /**
     * Method for retrieving all Courses. For conventions of a valid course see
     * Course entity. Method gets all courses.
     *
     * @return Empty list if no course , list of courses found instead
     * @throws ServiceFailureException if a problem during search occures.
     */
    public List<Course> getAll();

    /**
     * Method for retrieving Courses by language. For conventions of a valid
     * course see Course entity. Method gets course by input language.
     *
     * @param language language to be searched for.
     * @return Null if no such course in database, list of courses found instead
     * @throws IllegalArgumentPersistenceException if language is invalid(for
     * details see Language entity)
     * @throws ServiceFailureException if a problem during search occures.
     */
    public List<Course> findByLanguage(LanguageSpoken language) throws IllegalArgumentPersistenceException;

    /**
     * Method for retrieving Courses by name. For conventions of a valid course
     * see Course entity. Method gets course by input name.
     *
     * @param name name to be searched for.
     * @return Null if no such course in database, list of courses found instead
     * @throws IllegalArgumentPersistenceException if name is invalid(for
     * details see Course entity)
     * @throws ServiceFailureException if a problem during search occures.
     */
    public List<Course> findByName(String name) throws IllegalArgumentPersistenceException;
}
